﻿namespace UnityEditor
{
    using System;
    using UnityEngine;

    [CanEditMultipleObjects, CustomEditor(typeof(Transform))]
    internal class TransformInspector : Editor
    {
        private Vector3 m_EulerAngles;
        private Quaternion m_OldQuaternion = new Quaternion(1234f, 1000f, 4321f, -1000f);
        private SerializedProperty m_Position;
        private SerializedProperty m_Scale;

        public void OnEnable()
        {
            this.m_Position = base.serializedObject.FindProperty("m_LocalPosition");
            this.m_Scale = base.serializedObject.FindProperty("m_LocalScale");
        }

        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            Transform target = base.target as Transform;
            EditorGUILayout.PropertyField(this.m_Position, EditorGUIUtility.TempContent("Position"), new GUILayoutOption[0]);
            Vector3 position = target.position;
            if (((Mathf.Abs(position.x) > 100000f) || (Mathf.Abs(position.y) > 100000f)) || (Mathf.Abs(position.z) > 100000f))
            {
                EditorGUILayout.HelpBox("Due to floating-point precision limitations, it is recommended to bring the world coordinates of the GameObject within a smaller range.", MessageType.Warning);
            }
            Quaternion localRotation = target.localRotation;
            if (((this.m_OldQuaternion.x != localRotation.x) || (this.m_OldQuaternion.y != localRotation.y)) || ((this.m_OldQuaternion.z != localRotation.z) || (this.m_OldQuaternion.w != localRotation.w)))
            {
                this.m_EulerAngles = target.localEulerAngles;
                this.m_OldQuaternion = localRotation;
            }
            bool flag = false;
            foreach (Transform transform2 in base.targets)
            {
                flag |= transform2.localEulerAngles != this.m_EulerAngles;
            }
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = flag;
            this.m_EulerAngles = EditorGUILayout.Vector3Field("Rotation", this.m_EulerAngles, new GUILayoutOption[0]);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterUndo(base.targets, "Inspector");
                foreach (Transform transform3 in base.targets)
                {
                    transform3.localEulerAngles = this.m_EulerAngles;
                    if (transform3.parent != null)
                    {
                        transform3.SendTransformChangedScale();
                    }
                }
                base.serializedObject.SetIsDifferentCacheDirty();
                this.m_OldQuaternion = localRotation;
            }
            EditorGUILayout.PropertyField(this.m_Scale, EditorGUIUtility.TempContent("Scale"), new GUILayoutOption[0]);
            base.serializedObject.ApplyModifiedProperties();
        }
    }
}

